package javaApi.renameFile;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;
import java.net.URI;

public class HadoopRenameFile {
    public static void main(String[] args) throws IOException {
        String uri = args[0];
        Configuration conf = new Configuration();
        FileSystem fs = FileSystem.get(URI.create(uri), conf);
        Path currentName = new Path("/user/niit/test.txt");//当前文件名
        Path reName = new Path("/user/niit/test_2.txt");//修改后文件名
        boolean result = fs.rename(currentName, reName);
        System.out.println(result == true ? "修改成功" : "修改失败");

    }
}
